define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'stats/user/index' + location.search,
                    add_url: 'stats/user/add',
                    edit_url: 'stats/user/edit',
                    del_url: 'stats/user/del',
                    multi_url: 'stats/user/multi',
                    import_url: 'stats/user/import',
                    table: 'stats_user'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                searchFormVisible: true,
                columns: [
                    [
                        // {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', datetimeFormat:'YYYY-MM-DD', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'total', title: __('Total'), operate: false},
                        {field: 'increase', title: __('Increase'), operate: false},
                        {field: 'ordercount', title: __('Ordercount'), operate: false}
                    ]
                ]
            });
            $(".glyphicon.glyphicon-export.icon-share").before("导出");
            $(".glyphicon.glyphicon-export.icon-share").remove();
            $(".columns-right.pull-right>.btn.btn-default").remove();
            $(".columns-right.pull-right>.keep-open.btn-group").remove();
            $("#one > div > div.bootstrap-table > div.fixed-table-toolbar > div:nth-child(2)").remove();
            $(".pull-right.search").remove();
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});